﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Kinect.Toolbox.Xna
{

    public class XnaCursorEventArgs : EventArgs
    {
        public Vector2 Position;
        public XnaCursorEventArgs(float x, float y)
        {
            this.Position = new Vector2(x, y);
        }
    }

    public class GestureManagerXna : GestureManager
    {
        public EventHandler<XnaCursorEventArgs> LeftHandMovement;
        public EventHandler<XnaCursorEventArgs> RightHandMovement;

        protected MouseController rightHandController;
        protected MouseController leftHandController;


        protected GraphicsDeviceManager graphics;
        public GestureManagerXna(GraphicsDeviceManager graphics)
            :base(graphics.PreferredBackBufferWidth,graphics.PreferredBackBufferHeight)
        {
            
            this.graphics = graphics;

           
        }

        protected override void Initialize()
        {
            base.Initialize();
            if (graphics == null)
                return;

            rightHandController = new MouseController(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, Hand.Right);
            leftHandController = new MouseController(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, Hand.Left);

            leftHandController.MouseClicked += delegate(object sender, ClickEventArgs e)
            {
                if (RightHandClicked != null)
                    RightHandClicked(sender, e);
            };
            rightHandController.MouseClicked += delegate(object sender, ClickEventArgs e)
            {
                if (LeftHandClicked != null)
                    LeftHandClicked(sender, e);
            };
        }
    }
}
